# coding=utf-8
"""
实现一个简单的注册逻辑
flash消息回传前端，但需要对消息进行加密
"""

from flask import Flask, render_template, request, flash

app = Flask(__name__)

app.secret_key = "secret"


@app.route("/index")
def index():
    return render_template('register.html')


"""
改成/就可以测试
"""


@app.route("/register", methods=["GET", "POST"])
def register():
    username = request.form.get('username')
    password = request.form.get('password')
    retry_password = request.form.get('retryPassword')
    print('用户名: %s, 密码: %s, 确认密码: %s', username, password, retry_password)

    if not all([username, password, retry_password]):
        # 1、消息后台打印
        print("参数不完整")
        # 2、消息传回前端
        flash(u"参数不完整")


if __name__ == "__main__":
    # 在pycharm中，debug需要在configurations中配置开启
    app.run(debug=True)
